import { ref, computed } from 'vue'

// 自定义的 hook 都放到这个模块中
export const useFontColor = (initColor = '#ffffff') => {
  const fontColor = ref(initColor)
  const setFontColor = () => (window.document.body.style.color = fontColor.value)

  // react useState()
  // const [state, setState] = useState('abc')
  return [fontColor, setFontColor]
}

export const useCounter = (initCount = 0) => {
  const count = ref(initCount)
  const countPlus2 = computed(() => count.value * 2)
  const add = () => count.value++

  return {
    count,
    countPlus2,
    add
  }
}
